package ltd.zouzheng.myutils.spring.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * RestTemplate扩展工具自动装配
 *
 * @author zouzheng
 * @date 2021/4/13
 */
@Configuration
public class RestAutoConfigure {

    @Bean
    @ConditionalOnMissingBean(RestTemplate.class)
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

    @Autowired
    public void RestTemplateUtilFactory(RestTemplate restTemplate){
        RestTemplateExt restTemplateExt = new RestTemplateExt(restTemplate);
        RestTemplateUtil.setRestTemplateExt(restTemplateExt);
    }

}
